package com.zwps.biz.domain.service.impl;

import cn.hutool.core.collection.CollectionUtil;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.zwps.biz.api.model.vo.reservoirwaterlevel.ReservoirWaterLevelVO;
import com.zwps.biz.api.model.vo.ststbprp.ReservoirConstructionNodesDateVO;
import com.zwps.biz.api.model.vo.ststbprp.ReservoirConstructionNodesVO;
import com.zwps.biz.api.model.vo.ststbprp.ReservoirConstructionTypeVO;
import com.zwps.biz.api.model.vo.ststbprp.StStbprpBVO;
import com.zwps.biz.dal.db.object.ReservoirWaterLevelDO;
import com.zwps.biz.dal.db.object.StStbprpBDO;
import com.zwps.biz.domain.converter.ReservoirWaterLevelConverter;
import com.zwps.biz.domain.converter.StStbprpBConverter;
import com.zwps.biz.domain.service.StStbprpBService;
import com.zwps.biz.dal.db.dao.StStbprpBDAO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

/**
 *
 */
@Service
public class StStbprpBServiceImpl extends ServiceImpl<StStbprpBDAO, StStbprpBDO> implements StStbprpBService {

    @Autowired
    private StStbprpBDAO stbprpBDAO;

    @Override
    public List<StStbprpBVO> getStcd(String sttp) {
        List<StStbprpBDO> stbprpBDOS = stbprpBDAO.selectStcd(sttp);
        ArrayList<StStbprpBVO> list = new ArrayList<>();
        if (CollectionUtil.isNotEmpty(stbprpBDOS)) {
            for (StStbprpBDO stbprpBDO : stbprpBDOS) {
                StStbprpBVO stbprpBVO = StStbprpBConverter.INSTANCE.StStbprpBVO(stbprpBDO);
                list.add(stbprpBVO);
            }
        }
        return list;
    }

    @Override
    public List<StStbprpBVO> getStcdBySttp(String sttp) {
        List<StStbprpBDO> stbprpBDOS = stbprpBDAO.getStcdBySttp(sttp);
        ArrayList<StStbprpBVO> list = new ArrayList<>();
        if (CollectionUtil.isNotEmpty(stbprpBDOS)) {
            for (StStbprpBDO stbprpBDO : stbprpBDOS) {
                StStbprpBVO stbprpBVO = StStbprpBConverter.INSTANCE.StStbprpBVO(stbprpBDO);
                list.add(stbprpBVO);
            }
        }
        return list;
    }

    @Override
    public List<ReservoirConstructionTypeVO> getReservoirConstructionNodes() {

      List<ReservoirConstructionTypeVO>list=  stbprpBDAO.getType();
        for (ReservoirConstructionTypeVO reservoirConstructionTypeVO : list) {
            List<ReservoirConstructionTypeVO> byId = stbprpBDAO.getById(reservoirConstructionTypeVO.getId());
            reservoirConstructionTypeVO.setList(byId);
            reservoirConstructionTypeVO.setData(stbprpBDAO.getDataById(reservoirConstructionTypeVO.getId()));
            for (ReservoirConstructionTypeVO constructionTypeVO : byId) {
                List<ReservoirConstructionNodesVO> data= stbprpBDAO.getDataById(constructionTypeVO.getId());
                constructionTypeVO.setData(data);
            }
        }
        return list;
    }
}




